<?php
require '../script/mysqlconfig.php';

$name = $_POST['accountname'];

/* 连接数据库*/
$mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
if ($mysqli->connect_error) {
    die("数据库连接错误：" . $mysqli->connect_error);
}
/* 向数据表中传入用户的数据，方便后面对登录进行验证*/
if (isset($_POST["accountdel"])) {
    $sql = "DELETE FROM `users` WHERE `name` = '$name'";
    $mysqli->query($sql);
    if ($mysqli->affected_rows > 0) {
        echo "账号删除成功!";
    } else {
        die("账号删除失败!" . $mysqli->connect_error);
    }
}
// 关闭数据库连接
mysqli_close($mysqli);
